package logic

import (
	"context"
	"user/api/internal/svc"
	"user/api/internal/types"
	"user/rpc/userservice"

	"github.com/tal-tech/go-zero/core/logx"
)

type GetUserLogic struct {
	logx.Logger
	ctx    context.Context
	svcCtx *svc.ServiceContext
}

func NewGetUserLogic(ctx context.Context, svcCtx *svc.ServiceContext) GetUserLogic {
	return GetUserLogic{
		Logger: logx.WithContext(ctx),
		ctx:    ctx,
		svcCtx: svcCtx,
	}
}

func (l *GetUserLogic) GetUser(req types.GetRequest) (resp *types.GetResponse, err error) {
	// todo: add your logic here and delete this line
	idRequest := &userservice.IdRequest{
		Id: req.Id,
	}
	userInfo, err := l.svcCtx.UserService.GetUser(l.ctx, idRequest)
	l.Logger.Infov(userInfo)
	// userResponse := &types.GetResponse{
	// 	Code:    "200",
	// 	Message: "successful",
	// }
	// userResponse.Data.Name = userInfo.Name
	// userResponse.Data.Truename = userInfo.Truename
	userResponse := &types.GetResponse{
		Code:    "200",
		Message: "successful",
	}
	// id, _ := strconv.ParseInt(idRequest.Id, 10, 64)
	userResponse.Data.Id = int64(111)
	userResponse.Data.Name = "ZHAOKUN"
	userResponse.Data.Truename = "赵坤"

	return userResponse, err
}
